package com.huyanqi.front.rest.resource.impl;

import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.huyanqi.core.RetdObj;
import com.huyanqi.core.util.FileUploadUtils;
import com.huyanqi.entity.Share;
import com.huyanqi.front.rest.RespCode;
import com.huyanqi.front.rest.resource.ShareListResource;
import com.huyanqi.front.rest.resp.ShareListResp;
import com.huyanqi.front.rest.resp.ShareSimpleResp;
import com.huyanqi.front.rest.service.ShareRestService;

public class ShareResourceImpl implements ShareListResource{

	private ShareRestService restService;
	
	@Resource(name="ShareRestService")
	public void setRestService(ShareRestService restService) {
		this.restService = restService;
	}
	public ShareRestService getRestService() {
		return restService;
	}
	
	@Override
	public ShareListResp findLatestShare(Integer pageSize, Integer pageNum) {
		ShareListResp slp = new ShareListResp();
		try{
			RetdObj<List<Share>> retd = restService.findLatestShare(pageSize,pageNum);
			slp.setCode(RespCode.valueOf(retd.getCode()));
			slp.setData(retd.getRealObj());
		}catch (Exception e) {
			e.printStackTrace();
			slp.setCode(RespCode.EX_APP);
		}
		return slp;
	}
	
	@Override
	public ShareListResp findMyShare(Long uid) {
		ShareListResp slp = new ShareListResp();
		try{
			RetdObj<List<Share>> retd = restService.findMyShare(uid);
			slp.setData(retd.getRealObj());
			slp.setCode(RespCode.valueOf(retd.getCode()));
		}catch (Exception e) {
			e.printStackTrace();
			slp.setCode(RespCode.EX_APP);
		}
		return slp;
	}
	
}
